package designpattern.demo.creational.prototypepattern;


import java.util.ArrayList;

public class ThingDeepCopy implements Cloneable {
    //定义一个私有变量
    private ArrayList<String> arrayList = new ArrayList<String>();

    @Override
    public ThingDeepCopy clone() {
        ThingDeepCopy thing = null;
        try {
            thing = (ThingDeepCopy) super.clone();
            thing.setArrayList((ArrayList<String>) this.getArrayList().clone());
        } catch (CloneNotSupportedException e) {
            e.printStackTrace();
        }
        return thing;
    }

    public ArrayList<String> getArrayList() {
        return arrayList;
    }

    public void setArrayList(ArrayList<String> arrayList) {
        this.arrayList = arrayList;
    }
}